#include <cstdint>
#include <cstdlib>
#include <ctime>
#include <iostream>
using namespace std;

int main() {
    int n;
    cin >> n;

    int res = 33;

    
    int left = 0, right = n * res;
    int stride1 = ( right - res ) / ( n -1 );
    int stride2 = ( res - left ) / ( n - 1 );
    
    int num;
    for ( int i = 0; i < n; i++ ) {

        cin >> num;

        if ( num < left || num > right ) {
            cout << "Are you kidding me?" << endl;
        }
        else if ( num == res ) {
            cout << "Congratulations! You guessed it right!" << endl;
            break;
        }
        else if ( num < res ) {
            cout << "It's too small, please keep guessing!" << endl;
        }
        else if ( num > res ) {
            cout << "It's too big, please keep guessing!" << endl;
        }

        if ( i >= n - 2 ) {
            left  = res - 1;
            right = res + 1;
        }
        else {
            left += stride2;
            right -= stride1;
        }
    }
}

#include <iostream>
#include <utility>
using namespace std;
#include <vector>
#include <set>

int n, m, a, b;

bool foundFriends(const vector<int>& qsize,
                  const vector<pair<int, int>>& needAB,
                  bool needa, bool needb, bool needPeople,
                  vector<bool>& used, vector<int>& ids) {

    if (!needa && !needb && needPeople == 0) {
        return true;
    }

    for (int i = 0 ; i < qsize.size(); i++) {
        if (used[i]) {
            continue;
        }
        ids.push_back(i);
        if (foundFriends(qsize, needAB, needAB[i].first || needa, needAB[i].second ||
                         needb, needPeople - qsize[i], used, ids)) {
            

        } else {
            ids.pop_back();
        }
    }

    return false;


}

int main() {

    cin >>  n >>  m >>  a >> b;

    vector<bool> used(n, false);
    vector<int> qsize(n, 0);
    vector<pair<int, int>> needAB;

    for (int i = 0; i < n; i++) {
        cin >> qsize[i];
        set<int> temp;
        int major;
        bool needA = true, needB  = true;
        for (int j = 0; j < qsize[i]; j++) {
            cin >> major;
            if (needA) {
                needA = major ==  a ? false : true;
            }
            if (needB) {
                needB = major ==  b ? false : true;
            }
            temp.insert(major);
        }
        needAB.emplace_back(needA, needB);
    }

    for (int i = 0; i < n; i++) {
        if (!used[i]) {

            if (qsize[i] == m && ( !needAB[i].first &&  !needAB[i].second )) {
                used[i] = true;
                cout << i << endl;
                continue;
            }
            vector<int> qid;
            qid.push_back(i);
            used[i] = true;
            foundFriends(qsize, needAB, needAB[i].first, needAB[i].second, m - qsize[i],
                         used, qid);

            for (auto& id : qid) {
                cout << id << " ";
            }
            cout << endl;
        }
    }

}
